import http from '@/http/http'
import {
    AddCategoryModel,
    CategoryListParam,
    CategoryParam,
    CategoryType
} from './CategoryModel'

enum Api {
    getCategoryList = '/api/v1/category/getList',
    getParent = '/api/v1/category/parent',
    getSort = '/api/v1/category/getSort',
    addAndEditAndDel = '/api/v1/category/category'
}

// 获取文章分类列表
export const getCategoryTableApi = async (param: CategoryListParam) => {
    return await http.get(Api.getCategoryList, param)
}

// 获取上级分类
export const getParentCategoryApi = async () => {
    return await http.get(Api.getParent)
}

// 获得子分类sort最大值
export const getCategorySortApi = async (param: CategoryParam) => {
    return await http.getRestApi(Api.getSort, param)
}

// 新增
export const addCategoryApi = async (param: AddCategoryModel) => {
    return await http.post(Api.addAndEditAndDel, param)
}
// 编辑
export const editCategoryApi = async (param: AddCategoryModel) => {
    return await http.put(Api.addAndEditAndDel, param)
}
// 删除
export const delCategoryApi = async (param: CategoryParam) => {
    return await http.delete(Api.addAndEditAndDel, param)
}
